<script setup name="">
import { listExcel, getMeetingName } from '@/api/commission/rebateTC'
const { proxy } = getCurrentInstance()
const userList = ref([])
const loading = ref(true)
const showSearch = ref(true)
const dateRange = ref([])
const data = reactive({
  queryParams: {
    meetingName: '',
    packageName: undefined
  }
})
const { queryParams } = toRefs(data)

// 查询所有的台账名称
const TeamList = ref([])
function getMeeting () {
  getMeetingName().then(response => {
    TeamList.value = response.data
    queryParams.value.meetingName = response.data[0]
    console.log(TeamList.value, 888)
    getList()
  })
}
getMeeting()
/** 查询列表 */
function getList () {
  loading.value = true
  listExcel(proxy.addDateRange(queryParams.value)).then(res => {
    loading.value = false
    userList.value = res.data
  })
}

/** 搜索按钮操作 */
function handleQuery () {
  getList()
}
/** 重置按钮操作 */
function resetQuery () {
  dateRange.value = []
  proxy.resetForm('queryRef')
  queryParams.value.meetingName = TeamList.value[0]
  queryParams.value.packageName = undefined
  // proxy.$refs.deptTreeRef.setCurrentKey(null);
  handleQuery()
}
// 改变某一列单元格背景颜色
function tableCellStyle ({ row, columnIndex }) {
  let rowBackground = {}
  if (columnIndex >= 3 && columnIndex <= 9) {
    rowBackground.background = '#7bd3f7'
  }
  if (columnIndex >= 11 && columnIndex <= 15) {
    rowBackground.background = '#fee796'
  }

  return rowBackground
}
</script>

<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="台账名称" prop="meetingName">
        <el-select v-model="queryParams.meetingName" clearable filterable>
          <el-option v-for="item in TeamList" :label="item" :value="item" />
        </el-select>
      </el-form-item>
      <el-form-item label="套餐名称" prop="packageName">
        <el-input
          v-model="queryParams.packageName"
          placeholder="请输入套餐名称"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['']"
          >导出</el-button
        >
      </el-col> -->
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="userList"
      show-summary
      :cell-style="tableCellStyle"
      max-height="650"
      border
    >
      <el-table-column
        label="套餐ID"
        align="center"
        prop="packageId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="套餐名称"
        align="center"
        prop="packageName"
        width="700"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="返佣量"
        align="center"
        prop="rebateCount"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="充值达量(公司)"
        align="center"
        prop="rechargeAmountReached"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="激活达量(公司)"
        align="center"
        prop="activeAmountReached"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="追加激活达量(公司)"
        align="center"
        prop="plusActiveAmountReached"
        :show-overflow-tooltip="true"
      />

      <el-table-column
        label="运营商达量(公司)"
        align="center"
        prop="operatorAmountReached"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="分成佣金(公司)"
        align="center"
        prop="dividedCommission"
        width="100"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="激励分成(公司)"
        align="center"
        prop="incentiveSharing"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="公司佣金"
        align="center"
        prop="commission"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="合计(公司)"
        align="center"
        prop="companyCount"
        width="100"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="激活达量奖励(部门奖金奖励)"
        align="center"
        prop="deptActiveAmountReached"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="激活达量奖励(店铺佣金奖励)"
        align="center"
        prop="commissionActiveAmountReached"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="追加激活达量奖励(店铺佣金奖励)"
        align="center"
        prop="plusCommissionActiveAmountReached"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="佣金(店铺)"
        align="center"
        prop="deptCommission"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="分成佣金(店铺)"
        align="center"
        prop="deptDividedCommission"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="合计(店铺)"
        align="center"
        prop="deptCompanyCount"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="上级扣罚"
        align="center"
        prop="superDeduction"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="扣罚下级"
        align="center"
        prop="deductionSub"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="差额"
        align="center"
        prop="difference"
        width="150"
        :show-overflow-tooltip="true"
      />
    </el-table>
  </div>
</template>
